package com.wiegand.gui.text {
	import com.wiegand.loader.CssLoader;

	import flash.display.Sprite;
	import flash.text.AntiAliasType;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	/**
	 * @author kw
	 */
	 
	public class CssTextField extends Sprite{	
			
		static public function create( s : String, style : String, textWidth : int = 0, multiline: Boolean = false ) : TextField {
					
			var textfield : TextField = new TextField();		
							
			if( textWidth != 0 ){
				textfield.width = textWidth;
				textfield.wordWrap = true;			
				textfield.multiline = true;			
			}	
			
			if( multiline == true){
				textfield.multiline = true;							
			}
													
			textfield.autoSize = TextFieldAutoSize.LEFT;	
			textfield.selectable = false;							
			textfield.mouseWheelEnabled = false;
			textfield.embedFonts = true;				
			textfield.styleSheet = CssLoader.getInstance().getStyleSheet();
			textfield.htmlText = "<"+style+">"+s+"</"+style+">";	
			
			var css : Object = ( CssLoader.getInstance().getStyleSheet() as StyleSheet).getStyle( style );	
							
			if( css["tf_antialiastype"] == "advanced" ) textfield.antiAliasType = AntiAliasType.ADVANCED;
			else textfield.antiAliasType = AntiAliasType.NORMAL;
						
			if( css["tf_sharpness"] != undefined ) textfield.sharpness = Number( css["tf_sharpness"] );			
			if( css["tf_thickness"] != undefined ) textfield.thickness = Number( css["tf_thickness"] );		
		
			return textfield;
			
		}
	
	}
}
